#include <cstdio>

int main( )
{
    int a[ 100 ], N, A, B, len, i, cas = 1;
    while ( scanf("%d%d%d", &N, &A, &B) != EOF )
    {
        len = 0;
        while ( N )
        {
            a[ len++ ] = N % B;
            N /= B;
        }
        if ( !len )
            a[ len++ ] = 0;
        for ( i = 0; i < len - 1; i++ )
            if ( a[ i ] < A )
            {
                a[ i ] += B;
                a[ i + 1 ]--;
            }
        printf("Case %d:", cas++);
        for ( i = len - 1; i >= 0; i-- )
            printf(" %d", a[ i ]);
        printf("\n");
    }
    return 0;
}
